package com.senthink.gl.business.domain.entity;

import com.senthink.gl.business.common.entity.BaseEntity;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;

/**
 * 用户区域权限实体类
 *
 * @author zooqi@senthink.com
 * @date 2017/11/27
 */
@Entity
@Table(name = "gl_area_authority", indexes = {
        @Index(name = "idx_area_authority_area_id", columnList = "area"),
        @Index(name = "idx_area_authority_user_id", columnList = "user")})
@Getter
@Setter
public class UserAreaAuthority extends BaseEntity<Long> {

    /**
     * 用户
     */
    @ManyToOne(targetEntity = User.class)
    @JoinColumn(name = "user", referencedColumnName = "id", nullable = false)
    private User user;

    /**
     * 区域
     */
    @ManyToOne(targetEntity = Area.class)
    @JoinColumn(name = "area", referencedColumnName = "id", nullable = false)
    private Area area;

    /**
     * 用户设备权限列表(JSON数组)
     */
    @Lob
    @Column(name = "device_authority")
    private String deviceAuthority;
}
